/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Sik
 */
@Entity
@Table(name = "transporteur")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Transporteur.findAll", query = "SELECT t FROM Transporteur t"),
    @NamedQuery(name = "Transporteur.findByIdAdherent", query = "SELECT t FROM Transporteur t WHERE t.transporteurPK.idAdherent = :idAdherent"),
    @NamedQuery(name = "Transporteur.findByIdDeplacement", query = "SELECT t FROM Transporteur t WHERE t.transporteurPK.idDeplacement = :idDeplacement"),
    @NamedQuery(name = "Transporteur.findByNbKms", query = "SELECT t FROM Transporteur t WHERE t.nbKms = :nbKms")
})
public class Transporteur implements Serializable
{
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TransporteurPK transporteurPK;
    @Column(name = "nbKms")
    private Integer nbKms;
    @JoinColumn(name = "idDeplacement", referencedColumnName = "idDeplacement", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Deplacement deplacement;
    @JoinColumn(name = "idAdherent", referencedColumnName = "idAdherent", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Adherent adherent;

    public Transporteur()
    {
    }

    public Transporteur(TransporteurPK transporteurPK)
    {
        this.transporteurPK = transporteurPK;
    }

    public Transporteur(int idAdherent, int idDeplacement)
    {
        this.transporteurPK = new TransporteurPK(idAdherent, idDeplacement);
    }

    public TransporteurPK getTransporteurPK()
    {
        return transporteurPK;
    }

    public void setTransporteurPK(TransporteurPK transporteurPK)
    {
        this.transporteurPK = transporteurPK;
    }

    public Integer getNbKms()
    {
        return nbKms;
    }

    public void setNbKms(Integer nbKms)
    {
        this.nbKms = nbKms;
    }

    public Deplacement getDeplacement()
    {
        return deplacement;
    }

    public void setDeplacement(Deplacement deplacement)
    {
        this.deplacement = deplacement;
    }

    public Adherent getAdherent()
    {
        return adherent;
    }

    public void setAdherent(Adherent adherent)
    {
        this.adherent = adherent;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (transporteurPK != null ? transporteurPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transporteur))
        {
            return false;
        }
        Transporteur other = (Transporteur) object;
        if ((this.transporteurPK == null && other.transporteurPK != null) || (this.transporteurPK != null && !this.transporteurPK.equals(other.transporteurPK)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "Model.Transporteur[ transporteurPK=" + transporteurPK + " ]";
    }
    
}
